<template>
  <div>
    <table border="1px">
       <thead>
        <tr>
            <th>图片</th>
            <th>名称</th>
            <th>价格</th>
            <th>操作</th>
        </tr>
       </thead>
       <tbody>
        <tr v-for="item in arr" :key="item.id">
            <td><img :src="item.img" alt=""></td>
            <td>{{ item.goods_name }}</td>
            <td>{{ item.price }}</td>
            <td><button @click="shan(item.id)">删除</button></td>
        </tr>
       </tbody>
    </table>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
//   name:'',
  data() {
    return {
      arr:[],         
       a:'',        
       b:'',   
       c:'' 
    }
  },
  mounted() {  
    this.list()  
    this.fen()
  },  
  methods: {   
    list(){   
        axios.get('https://liu.zzgoodqc.cn/goodsx/goodslist')       
        .then(res=>{                       
          console.log(res.data)
          this.arr =res.data.data      
        })     
        .catch(e=>{       
          console.log(e)           
        })      
    } ,
    fen(){
        axios({
            url:'https://liu.zzgoodqc.cn/goodsx/listByPage',  
            method:'get',
            data:{
               page:2,
               limit:3,
            }
        })
        .then(res=>{                       
          console.log(res)
        //   this.arr =res.data.data      
        })     
        .catch(e=>{       
          console.log(e)           
        })      
    },
    shan(i){
        axios({
            url:'https://liu.zzgoodqc.cn/goodsx/delete?id='+i,  
             method:'get',
        })
        .then(()=>{                       
        //   console.log(res)
        //   this.arr =res.data.data      
           this.list()
        })     
        .catch(e=>{       
          console.log(e)           
        })      
    }
  },
}
</script>
<style lang='less' scoped>

</style>